package controller

import (
	"github.com/gin-gonic/gin"
	"lab.com/biz"
	"lab.com/request"
)

type cBanner struct {
	APIBase
}

// Banner .
var Banner = cBanner{}

// List return banner list (all user)
func (banner *cBanner) List(c *gin.Context) {
	res, err := biz.Banner.List(c)
	banner.Resp(c, res, err)
}

// Add return banner add (admin)
func (banner *cBanner) Add(c *gin.Context) {
	inputParams := request.BannerAddReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		banner.Resp(c, nil, err)
		return
	}

	err := biz.Banner.Add(c, inputParams)
	banner.Resp(c, nil, err)
}

// ListInManage return banner list in manage (admin)
func (banner *cBanner) ListInManage(c *gin.Context) {
	inputParams := request.BannerListInManageReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		banner.Resp(c, nil, err)
		return
	}

	res, err := biz.Banner.ListInManage(c, inputParams)
	banner.Resp(c, res, err)
}


// Edit return banner edit (admin)
func (banner *cBanner) Edit(c *gin.Context) {
	inputParams := request.BannerEditReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		banner.Resp(c, nil, err)
		return
	}

	err := biz.Banner.Edit(c, inputParams)
	banner.Resp(c, nil, err)
}

// Delete return banner delete (admin)
func (banner *cBanner) Delete(c *gin.Context) {
	inputParams := request.BannerDeleteReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		banner.Resp(c, nil, err)
		return
	}

	err := biz.Banner.Delete(c, inputParams)
	banner.Resp(c, nil, err)
}


// Show return banner show (admin)
func (banner *cBanner) Show(c *gin.Context) {
	inputParams := request.BannerShowReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		banner.Resp(c, nil, err)
		return
	}

	err := biz.Banner.Show(c, inputParams)
	banner.Resp(c, nil, err)
}